package gui;

import java.awt.BorderLayout;
import java.awt.event.MouseListener;
import java.util.Vector;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.border.Border;
import javax.swing.border.EtchedBorder;
import javax.swing.event.ListSelectionListener;

public class ListPanel extends JPanel{
	JLabel label;
	public JList data;
	public ListPanel(JList _data,String title) 
	{
		super(new BorderLayout());
        data = _data;
        data.setName(title);
        JScrollPane scrollPane = new JScrollPane(data);

        
        label = new JLabel(title);
        add(label,BorderLayout.NORTH);
        add(scrollPane,BorderLayout.CENTER);
        Border loweredetched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
        
        setBorder(loweredetched);
	}
	
	public void addListSelectionListener(ListSelectionListener l)
	{
		data.addListSelectionListener(l);
	}
	public void addMouseListener(MouseListener m)
	{
		data.addMouseListener(m);
	}
	public String getSelectedValue()
	{
		return (String) data.getSelectedValue();
	}
	
	public void update(Vector<String> _data)
	{
		data.setListData(_data);
	}

}
